package com.tiger.test 
{
	import com.tiger.anim.BmdArray;
	import com.tiger.anim.BmdMovieClip;
	import com.tiger.avatar.RoleAvatar;
	import com.tiger.mgr.ResMgr;
	import com.tiger.mgr.TickMgr;
	import flash.display.DisplayObjectContainer;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.net.URLRequest;
	
	/**
	 * ...
	 * @author wmTiger
	 */
	public class Test extends Sprite 
	{
		
		public function Test():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			TickMgr.instance.init(stage);
			
			//var loader:Loader = new Loader();
			//initLoad(loader.contentLoaderInfo);
			//loader.load(new URLRequest("1002.swf"));
			
			loadSwf();
		}
		
		private function loadSwf():void 
		{
			var url:String = "1002.swf";
			var swf:MovieClip = ResMgr.instance.getSwf(url);
			if (swf == null) 
			{
				ResMgr.instance.loadSwf(url, url, function ():void 
				{
					trace("loadSwf 1001.swf");
				});
			}
			else
			{
				
			}
		}
		
		private function initLoad(contentLoaderInfo:LoaderInfo):void 
		{
			contentLoaderInfo.addEventListener(Event.INIT, onInit);
		}
		
		private function onInit(e:Event):void 
		{
			var loader:Loader = e.currentTarget.loader as Loader;
			var mc:MovieClip = (loader.contentLoaderInfo.content as MovieClip).getChildAt(0) as MovieClip;
			loader.unloadAndStop();
			var bmdArr:BmdArray = new BmdArray(mc);
			var bmdmc:BmdMovieClip = new BmdMovieClip(bmdArr);
			var avatar:RoleAvatar = new RoleAvatar(bmdmc);
			addChild(avatar);
			avatar.x = 100;
			avatar.y = 100;
			//avatar.stand();
			//avatar.move(400, 100);
			var ps:Array = [new Point(200, 100), new Point(200, 200), new Point(100, 200), new Point(100, 300)];
			avatar.movePath(ps, avatar.teleport);
		}
		
	}

}